//
// Parse.cpp for  in /home/goldbe_y//cpp/Maths/206observ
//
// Made by yoni goldberg
// Login   <goldbe_y@epitech.net>
//
// Started on  Mon May  2 15:13:56 2011 yoni goldberg
// Last update Wed Oct 17 10:24:53 2012 yoni goldberg
//

#include <cstdlib>

#include "Parse.hpp"
#include "convert.hpp"

Parse::Parse(const std::string &str)
{
  std::string			temp;
  std::ifstream			file(str.c_str());

  if (file.is_open())
    {
      getline(file, temp);
      _nb_task = string_to_var<int>(temp);
      for (int i = 0; i < _nb_task; i++)
	{
	  getline(file, temp);
	  _task += temp[0];
	  temp.erase(0, 2);
	  _time.push_back(string_to_var<float>(temp));
	}
      getline(file, temp);
      _nb_contrainte = string_to_var<int>(temp);
      for (int i = 0; i < _nb_contrainte; i++)
	{
	  getline(file, temp);
	  _contrainte.push_back(temp);
	}
      file.close();
    }
}

Parse::~Parse()
{
}

std::string			&Parse::get_task()
{
  return _task;
}

int				Parse::getNbTask() const
{
  return _nb_task;
}

std::vector<float>		Parse::get_time()
{
  return _time;
}

std::vector<std::string>	&Parse::get_contrainte()
{
  return _contrainte;
}

int				Parse::getNbContrainte() const
{
  return _nb_contrainte;
}
